<!-- -----------------------------------------------物资统计表------------------------------------ -------- -->
<template>
  <div>
    <el-form :inline="true" :model="listQuery" class="demo-form-inline">
      <el-form-item label="货物名称" prop="name">
        <el-input v-model="listQuery.stlName" placeholder="货物名称"></el-input>
      </el-form-item>
      <el-form-item label="材质" prop="Typename">
        <el-select v-model="listQuery.textureID" placeholder="全部">
          <el-option label="金属" value="C4B257EC-15AC-64AF-8581-8A86A6355041"></el-option>
          <el-option label="橡胶" value="EF19EE03-63AC-923E-4EC0-F53864FAF4DA"></el-option>
          <el-option label="塑料" value="B8A7DAB5-FBCB-380C-EA08-84A67B6BA2FA"></el-option>
          <el-option label="液体" value="F18A8F75-885B-6020-41F1-83869AD88184"></el-option>
          <el-option label="纸质" value="FAE70E35-24D4-7995-6670-F8BE2774E517"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="产地" prop="addr">
        <el-select
          v-model="listQuery.addrID"
          placeholder="请选择地址"
          style="float: left"
        >
          <el-option label="中国" value="11639B30-862A-C011-F89C-B4DEB460A3F8"></el-option>
          <el-option label="美国" value="49B3FF3C-8B9E-B36D-E521-731623D99D84"></el-option>
          <el-option label="俄罗斯" value="16A2BC18-D2FD-A141-29D4-96ECEA43EEBD"></el-option>
          <el-option label="法国" value="E0133E44-FE4B-064B-DD13-40345488B650"></el-option>
          <el-option label="德国" value="3579431F-3C46-29EE-838E-47C4BF60324A"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="统一区间" prop="star">
        <el-input v-model="listQuery.createTime" type="date" placeholder="选择日期"></el-input>
      </el-form-item>
      <el-col class="line" :span="2">-</el-col>
      <el-form-item label="--" prop="end">
        <el-input v-model="listQuery.createTime" type="date" placeholder="选择日期"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmitSelect" icon="el-icon-search">查询</el-button>
      </el-form-item>
    </el-form>
    
    <el-table :data="tableData" border stripe style="width: 100%; margin-bottom: 20px">
      <el-table-column prop="stlName" label="货物名称"></el-table-column>
      <el-table-column prop="typeName" label="类型"></el-table-column>
      <el-table-column prop="textureName" label="材质"></el-table-column>
      <el-table-column prop="skuName" label="规格"></el-table-column>
      <el-table-column prop="addrID" label="产地" ></el-table-column>
      <el-table-column prop="cargoNum" label="期间采购数量"></el-table-column>
      <el-table-column prop="goodsNum" label="期间领用数量"></el-table-column>
      <el-table-column prop="surplusNum" label="期间结余数量"></el-table-column>
    </el-table>
    <div class="block">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="PaIndex"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="PaSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      tableData: [],
      PaIndex: 1,
      PaSize: 5,
      total: 0,
      listQuery:
      {
        cargoName: '',
        textureID: '',
        addrID: '',
        createTime:''
      },
    };
  },
  created: function () {
    this.axios
      .get("https://localhost:44331/api/app/statistical_Goods", {
        params: { PageIndex: this.PaIndex, PageSize: this.PaSize },
      })
      .then((res) => {
        (this.tableData = res.data.items),
          (this.total = res.data.totalCount);
      });
  },
  methods: {
    
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.axios
        .get("https://localhost:44331/api/app/statistical_Goods", {
          params: { PageIndex: this.paIndex, PageSize: val },
        })
        .then(
          (res) => {
           (this.tableData = res.data.items),
          (this.total = res.data.totalCount);
          }
        );
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.axios
        .get("https://localhost:44331/api/app/statistical_Goods", {
          params: { PageIndex: val, PageSize: this.PaSize },
        })
        .then(
          (res) => {
            (this.tableData = res.data.items),
          (this.total = res.data.totalCount);
          }
        );
    },
    onSubmitSelect(formInline) {
      this.axios
        .get("https://localhost:44331/api/app/statistical_Goods?name=" +
            this.formInline.cargoName +
            "&Typename=" +
            this.formInline.textureID +
            "&addr=" +
            this.formInline.addrID +
            "&star=" +
            this.formInline.createTime+ 
            "&end=" +
            this.formInline.createTime
        )
        .then((res) => {
          this.tableData = res.data.items;
          this.total = res.data.totalCount;
        });
    },
  },
};
</script>

<style scoped>
.table-grid-content {
  border-radius: 4px;
  height: 50px;
  background: #ebeef5;
  padding: 10px;
}
</style>